<?php

class Default_IndexController extends Zend_Controller_Action {

    private $personaDao;

    public function init() {
        $auth = Zend_Auth::getInstance();

        if ($auth->hasIdentity()) {

            if (!empty($auth->getIdentity()->id)) {
                $usuarioDao = new Doctrine_Model_UsuariosDoctrineDao();
                $this->view->usuario = $usuarioDao->obtenerPorId($auth->getIdentity()->id);
            }
        } else {
            $this->_helper->redirector('index', 'login', 'admin');
        }
        $this->_session = new Zend_Session_Namespace('tema');

        if ($this->_session->tema) {
            $this->view->logo = 'logoVerde.jpg';
            $this->view->colorFondo = '#4D9473';
            $this->view->colorFuente = '#FFF';
            $this->view->colorFuenteContenido = '#000';
            $this->view->colorContenido = '#C6DC94';
            $this->view->colorMenu = 'navbar-inverse';
            $this->view->colorFondoMenuLateral = '#DFDFDF';
        } else {
            $this->view->logo = 'logoBlanco.jpg';
        }
    }

    public function preDispatch() {
        
    }

    public function indexAction() {
        
    }

    public function enconstruccionAction() {
        
    }

    public function listadoAction() {
        $this->_helper->_layout->setLayout('layout_tabs_1');
    }

    public function listado2Action() {

        $this->_helper->_layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();
        $jsonData = array('page' => $page, 'total' => $total, 'rows' => array());

        $entry = array('persona_id' => 'sdfsd', 'cell' => array('name' => 'sdfsd', 'iso' => 'sdfsd', 'printable_name' => $row['printable_name'], 'iso3' => $row['iso3'], 'numcode' => $row['numcode']),);
        $jsonData['rows'][] = $entry;
        $json = Zend_Json::encode($jsonData);

        echo $json;
    }

    public function pruebaAction() {
        $this->personaDao->pruebaNativoSql();
    }

}

